<?php
require_once "Common/database.php";
if($_POST[status]=='')
{
$_POST[status]='%';
}
if($_POST[faulty]=='')
{
$_POST[faulty]='Both';
}
if($_POST[serial]=='')
{
$_POST[serial]='%';
}
if($_POST[id]=='')
{
$_POST[id]='%';
}
if($_POST[type]=='')
{
$_POST[type]='%';
}
echo '<p><h3>Equipment Log</h3><FORM action="index.php?p=iview" method="POST">';
echo '<table border=1>';

echo '<tr><td>Serial Number : <input type="text" name="serial" size="10" value='.$_POST[serial].'>';
echo '<td>ID: <input type="text" name="id" size="10" value='.$_POST[id].'>';
echo '<tr><td style="border:0px solid ;" valign="top">Status';
#echo '<select name=status><option>'.$_POST[status].'</option><option></option>';
#genIStatus();
echo '<input type="text" name="status" size="10" value="'.$_POST[status].'">';
echo ' </td>';
echo '<td style="border:0px solid ;" valign="top">Faulty ?<select name="faulty"><option>'.$_POST[faulty].'</option><option></option><option>Both</option><option>Yes</option><option>No</option></td><td><input type="submit" value="Go"></td></tr>';
echo '<tr><td style="border:0px solid ;valign="top">Type : <input type="text" name="type" size="10" value="'.$_POST[type].'"></form></td></tr>';
echo '</table>';
echo '<table border=1>';
echo '<tr><td>ID</td><td>Branch</td><td>Department</td><td>Type of Equpment</td><td>Serial Number</td><td>Checked by</td><td>Date Checked</td><td>Reason</td><td>Action</td><td>Faulty</td><td>Status</td></tr>';
if($_POST[status]=='All')
{
$_POST[status]='%';
}

if($_POST[faulty]=='Both')
{
$_POST[faulty]='%';
}
$result = mysql_query("SELECT * FROM tblInventory WHERE Status LIKE '$_POST[status]' AND Faulty LIKE '$_POST[faulty]' AND Serial LIKE '$_POST[serial]' AND `key` LIKE '$_POST[id]' AND Type LIKE '$_POST[type]' ");
#echo $result;
echo "<br>Returned : <b>", mysql_affected_rows() ,"</b> Rows";
$i=0;
while($row = mysql_fetch_array($result))
  {
echo '<tr id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\'#F0F0F0\';" onmouseout="row'.$i.'.style.backgroundColor=\'#6495ED\';" onclick="location.href=\'index.php?m=i&p=iupdate&f2='.$row['key'].' \'"><td>'.$row['key'].'</td><td>'.$row['Branch'].'</a></td><td>'.$row['Department'].'</td><td>'.$row['Type'].'</td><td>'.$row['serial'].'</td><td>'.$row['CheckedBy'].'</td><td>'.$row['DateChecked'].'</td><td>'.$row['Reason'].'</td><td>'.$row['Action'].'</td><td>'.$row['Faulty'].'</td><td>'.$row['Status'].'</td></tr>';
  $i=$i+1;

  }
echo '</table>';
echo '<a href="index.php?p=iadd">Add</a>';

?>

